package jdbc;

import com.mysql.jdbc.*;

import java.sql.DriverManager;
//import com.mysql.jdbc.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class dbmanager {
	
	static final String JDBC_DRIVER="com.mysql.jdbc.Driver";
	static final String DB_URL="jdbc:mysql://localhost/employee";
	static final String user="employe";
	static final String pass="nandini";
	
	//public ResultSet retriveData() {
	public static void main(String[] args){
	
		Connection conn=null;
		java.sql.Statement stmt=null;
		ResultSet rs=null;
		
		try{
		Class.forName("com.mysql.jdbc.Driver");
		conn=(Connection) DriverManager.getConnection
				(DB_URL,user,pass);
		stmt=conn.createStatement();
		rs=stmt.executeQuery("select *from emp");
		while(rs.next()){
			System.out.println(rs.getInt(1)+" "+ rs.getDouble(4));
			//System.out.println(rs.getDouble(4));
						
		}
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
		finally{
			try{
				if(conn != null)
					conn.close();
				if(stmt != null)
					stmt.close();
			}
		catch(SQLException e){
			e.printStackTrace();
		}
		}
			//return rs;
		}
		
	}
		
	


